{template 'header'}
<link href="./resource/css/app.css" rel="stylesheet">
<ul class="nav nav-tabs">
    <li class="active"><a href="javascript:;">奖品订单管理</a></li>
</ul>

<div class="panel panel-default">
    <div class="table-responsive panel-body">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
                <th style="width:80px;"> 选择</th>
                <th>id</th>
                <th>抽奖id</th>
                <th>奖品类型</th>
                <th>发起用户</th>
                <th>奖品名</th>
                <th>图片</th>
                <th>中奖用户</th>
                <th>状态</th>
                <th>时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {loop $luck_goods_info['list'] $item}
            <tr class="odd gradeX">
                <td><input type="checkbox" name="collect" value="{$item['id']}" />{$item['id']}</td>
                <td>{$item['id']}</td>
                <td>{$item['luck_id']}</td>
                <td>{php echo $item['type'] ==1 ? "实物" : "虚拟" }</td>
                <td>{$item['initiator']}</td>
                <td>{$item['name']}</td>
                <td><img src="{php echo tomedia($item['image'])}" style="width:60px; height: 40px"></td>
                <td>{$item['winners']}</td>
                <td>{$item['status_str']}</td>
                <td>{php echo date('Y-m-d H:i:s',$item['created'])}</td>
                <td>
                    {if $item['status'] ==1}
                    <a href="{php echo $this->createWeburl('voteSend', array('id'=>$item['id']));}" class="btn btn-primary btn-sm">发货</a>&nbsp;&nbsp;
                    {elseif $item['status'] == 2}
                    <a href="javascript:;" data-id="{$item['id']}" class="btn btn-success btn-sm success">完成</a>&nbsp;&nbsp;
                    <a href="javascript:;" data-id="{$item['id']}" class="btn btn-warning btn-sm cancel">取消</a>&nbsp;&nbsp;
                    {elseif $item['status'] ==3}
                    <a href="javascript:;" class="btn btn-info btn-sm">已完成</a>
                    {/if}
                    <a class="btn btn-danger btn-sm del"  data-id="{$item['id']}"  href="javascript:;">删除</a>&nbsp;&nbsp;
                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
    </div>
    <div class="css" style="margin-bottom: 15px">
        <input  type="button" class="btn btn-default" id="allCheck" value="全选"/>
        <input type="button" class="btn btn-default" id="noCheck" value="全不选"/>
        <input type="button" class="btn btn-default" id="revCheck" value="反选"/>
        <input type="button" class="btn btn-success" id="audit" value="批量删除"/>
    </div>
    {$luck_goods_info['pages']}
</div>
<script type="application/javascript">
    $(function () {
        $('.del').click(function () {
            if (!confirm('确认要' + $(this).html())) {
                return false;
            }
            id = $(this).data('id');
            $.post('', {id:id, op:'del'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('删除失败');
                }

            }, 'json')
        });

        $('.cancel').click(function () {
            if (!confirm('确认要' + $(this).html())) {
                return false;
            }
            id = $(this).data('id');
            $.post('', {id:id, op:'cancel'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('取消失败');
                }

            }, 'json')
        });

        $('.success').click(function () {
            if (!confirm('确认要' + $(this).html())) {
                return false;
            }
            id = $(this).data('id');
            $.post('', {id:id, op:'success'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('操作失败');
                }

            }, 'json')
        });
    });


    $(function() {
        // 全选
        $("#allCheck").click(function(){
            $(":checkbox").prop("checked",true);
        });
        // 全不选
        $("#noCheck").click(function(){
            $(":checkbox").prop("checked",false);
        });
        // 反选
        $("#revCheck").click(function(){
            $(":checkbox").each(function(){
                var check = $(this).prop("checked");
                $(this).prop("checked",!check);
            });

        });

        //通过审核
        $("#audit").click(function () {
            var chk_value =[];
            $('input[name="collect"]:checked').each(function(){
                chk_value.push($(this).val());
            });
            var taskIds = chk_value.join(",");

            $.post('', {taskIds:taskIds, op:'deleteAll'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('删除失败');
                }
            }, 'json')

        })

        //拒绝审核
        $("#refuse").click(function () {
            var chk_value =[];
            $('input[name="collect"]:checked').each(function(){
                chk_value.push($(this).val());
            });
            var taskIds = chk_value.join(",");

            $.post('', {taskIds:taskIds, op:'refuse'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('删除失败');
                }

            }, 'json')

        })
    });



</script>